package com.guet.controller.user;

import com.guet.DTO.DocumentDTO;
import com.guet.DTO.DocumentPageDTO;
import com.guet.VO.DocumentVO;
import com.guet.result.PageResult;
import com.guet.result.Result;
import com.guet.service.DocumentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("studentDocumentController")
@RequestMapping("/student/document")
@Slf4j
@CrossOrigin
public class DocumentController {
    @Autowired
    private DocumentService documentService;

    /**
     * 分页查询文档
     *
     * @param documentPageDTO
     * @return
     */
    @PostMapping
    public Result<PageResult> getDocumentList(@RequestBody DocumentPageDTO documentPageDTO) {
        log.info("documentPageDTO:{}", documentPageDTO);
        PageResult result = documentService.list(documentPageDTO);
        return Result.success(result);
    }

    /**
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result<DocumentVO> getDocumentDetail(@PathVariable Integer id) {
        log.info("id:{}", id);
        DocumentVO documentVO = documentService.queryById(id);
        return Result.success(documentVO);
    }
}
